package polsl.biai.projekt.client;


import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * shows Popup
 * @author Jacek
 *
 */
public class MyPopup extends PopupPanel {

	private VerticalPanel panel = new VerticalPanel();
	private Button button; 
	private Label label;
	
	public MyPopup()
	{
		super(false);
	}

	public MyPopup(String s) {

	}
	
	/**
	 * shows a popup message with String s with close button
	 * @param s
	 */
	public void showPopupWithClose(String s) {
		final MyPopup popup = this;
		label = new Label(s);
		button =new Button("Zamknij");
		panel.add(label);
		panel.add(button);
		setWidget(panel);	
		popup.setPopupPosition(800, 300);
		popup.show();
		//disallows user to click outside the popup
		this.setGlassEnabled(true);
		this.setModal(true);
		popup.button.addClickHandler(new ClickHandler() {

			@Override
			public void onClick(ClickEvent event) {
				popup.hide();
			}

		});
	}
	
	/**
	 * shows popup message with String s
	 * without any button
	 * @param s
	 */
	public void showPopupWithoutClose(String s)
	{
		label = new Label(s);
		panel.add(label);
		setWidget(panel);	
		this.setPopupPosition(800, 300);
		this.show();
		//disallows user to click outside the popup
		this.setGlassEnabled(true);
		this.setModal(true);
		
	}
}

